<?php

use Cartalyst\Sentry\Facades\Laravel\Sentry as Sentry;

Route::filter('probackend.before', function() {

    // Disable the Throttling Feature
    Sentry::getThrottleProvider()->disable();

    if (Request::segment(2) == "deny" || Request::segment(2) == "lang") {
        
    } else {
        if (!Sentry::check() && !(Request::segment(2) == "login" || Request::segment(2) == "authen")) {
            return Redirect::route(Request::segment(1) . '.login');
        }

        if (Sentry::check() && Request::segment(2) == "login") {
            return Redirect::route(Request::segment(1) . '.dashboard');
        }
    }

    if (Session::has('language')) {
        Config::set('application.language', Session::get('language'));
        App::setLocale(Session::get('language'));
    }
});
